** ANALYSIS OF THE MAIN DATASET
** Does Land Quality Increase the Power of Traditional Leaders in Contemporary Africa?
** Journal of Politics
** Kate Baldwin and Joan Ricart-Huguet

clear all

* Global macros
global replication "C:\Users\jricart-huguet\Dropbox\research\Persistence_of_TAs\submission\JoP\replication"
global figures_tables "C:\Users\jricart-huguet\Dropbox\research\Persistence_of_TAs\submission\JoP\replication\figures_tables"
global esttabformat b(%8.2f) p(%8.2f) obs ar2(%8.2f) r2(%8.2f) star(+ 0.10 * 0.05 ** 0.01)
cd "$replication"

use "$replication\dataset.dta", clear


****************
*** ANALYSIS ***
****************

* Models for Tables 1 and A.4
* Baseline models
eststo m1a: xi: qui reg q65 landqual v33 v5 i.country1, cluster(murdock_name) 
eststo m1b: xi: qui reg TLland landqual v33 v5 i.country1, cluster(murdock_name)
eststo m1c: xi: qui reg TLdisputes landqual v33 v5 i.country1, cluster(murdock_name) 
esttab m1a m1b m1c, order(landqual) keep(landqual) $esttabformat

* landqual - adding v5 so it's more like a Diff-in-Diff
eststo m2a: xi: qui reg q65 landqual v33 v5 lnpopd00 i.country1, cluster(murdock_name)
eststo m2b: xi: qui reg TLland landqual v33 v5 lnpopd00 i.country1, cluster(murdock_name)
eststo m2c: xi: qui reg TLdisputes landqual v33 v5 lnpopd00 i.country1, cluster(murdock_name)
esttab m2*, order(landqual) drop(*country*) $esttabformat

* additional controls: ecodivmaj with group cluster indicators and distance to capital control
eststo m3a: xi: qui reg q65 landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 rural, cluster(murdock_name)
eststo m3b: xi: qui reg TLland landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 rural, cluster(murdock_name)
eststo m3c: xi: qui reg TLdisputes landqual lnpopd00 v33 v5 i.country1 ecodivmaj cluster_power dist_cap100 rural, cluster(murdock_name)
esttab m3*, order(landqual ecodivmaj cluster_* dist_cap100* *pop*) drop(*country*) $esttabformat

* Models for Tables 1 and A.5 
* Baseline models
eststo m1arur: xi: qui reg q65 landqual v33 v5 i.country1 if rural==1, cluster(murdock_name) 
eststo m1brur: xi: qui reg TLland landqual v33 v5 i.country1 if rural==1, cluster(murdock_name)
eststo m1crur: xi: qui reg TLdisputes landqual v33 v5 i.country1 if rural==1, cluster(murdock_name)
esttab m1*rur, order(landqual) drop(*country*) $esttabformat

* landqual - adding v5 so it's more like a Diff-in-Diff
eststo m2arur: xi: qui reg q65 landqual v33 v5 lnpopd00 i.country1 if rural==1, cluster(murdock_name)
eststo m2brur: xi: qui reg TLland landqual v33 v5 lnpopd00 i.country1 if rural==1, cluster(murdock_name)
eststo m2crur: xi: qui reg TLdisputes landqual v33 v5 lnpopd00 i.country1 if rural==1, cluster(murdock_name)
esttab m2*rur, order(landqual) drop(*country*) $esttabformat

* additional controls: ecodivmaj with group cluster indicators and distance to capital control
eststo m3arur: xi: qui reg q65 landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 if rural==1, cluster(murdock_name)
eststo m3brur: xi: qui reg TLland landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 if rural==1, cluster(murdock_name)
eststo m3crur: xi: qui reg TLdisputes landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 if rural==1, cluster(murdock_name)
esttab m3*rur, order(landqual ecodivmaj cluster_* dist_cap100* *pop*) drop(*country*) $esttabformat

* Table 1. Table with models 3, 6, 9 for full sample and for rural sample

preserve
cd "$figures_tables"
label var landqual "Land quality (2002)"
label var ecodivmaj "Ecological diversity (2002)"
label var lnpopd00 "Population density (2000)"
label var v5 "Pre-colonial dependence on agriculture"
label var v33 "Pre-colonial political centralization"
label var cluster_power "Politically powerful ethnic cluster"
label var dist_cap100 "Distance from ethnic homeland to capital"
esttab m3a m3b m3c m3arur m3brur m3crur using main_results.tex, replace label /// 
mgroups("Full sample" "Rural sample", pattern(1 0 0 1 0 0) /// 
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) /// 
varlabels(, elist(landqual \hline rural \hline)) /// 
indicate("Country FE = *country*") /// 
mtitles("\shortstack{Influence}" "Land" "Disputes" "Influence" "Land" "Disputes") ///
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// 
order(landqual v33 v5 lnpopd00 ecodivmaj cluster_power dist_cap100 rural) keep(landqual v5 ecodivmaj lnpopd00 v33 cluster_power dist_cap100 rural) ///
b(2) se(2) stats(N r2 r2_a, fmt(0 2) labels("Individuals (N)" "\(R^{2}\)" "Adj. \(R^{2}\)")) //
cd "$replication"
restore


* Models for Tables 2 and A.10
* Mechanisms: population density with 25km and 50km cutoffs, rural sample

foreach x in 25 50 {
sum popd00, d
eststo popdensrur`x'h_q65: xi: reg q65 landqual v33 v5  i.country1 ecodivmaj cluster_power dist_cap100 if rural==1 & popd00>=`x', cluster(murdock_name)
eststo popdensrur`x'l_q65: xi: reg q65 landqual v33 v5  i.country1 ecodivmaj cluster_power dist_cap100 if rural==1 & popd00<`x', cluster(murdock_name)

eststo popdensrur`x'h_land: xi: reg TLland landqual v33 v5  i.country1 ecodivmaj cluster_power dist_cap100 if rural==1 & popd00>=`x', cluster(murdock_name)
eststo popdensrur`x'l_land: xi: reg TLland landqual v33 v5  i.country1 ecodivmaj cluster_power dist_cap100 if rural==1 & popd00<`x', cluster(murdock_name)

eststo popdensrur`x'h_disp: xi: reg TLdisputes landqual v33 v5  i.country1 ecodivmaj cluster_power dist_cap100 if rural==1 & popd00>=`x', cluster(murdock_name)
eststo popdensrur`x'l_disp: xi: reg TLdisputes landqual v33 v5  i.country1 ecodivmaj cluster_power dist_cap100 if rural==1 & popd00<`x', cluster(murdock_name)
}
esttab popdensrur25h* popdensrur25l*, order(landqual v33) drop(*country*) $esttabformat
esttab popdensrur50h* popdensrur50l*, order(landqual v33) drop(*country*) $esttabformat

* Tables 2 and A.10
preserve
foreach x in 25 50 {
cd "$figures_tables"
label var landqual "Land quality (2002)"
esttab popdensrur`x'h_q65 popdensrur`x'h_land popdensrur`x'h_disp popdensrur`x'l_q65 popdensrur`x'l_land popdensrur`x'l_disp using popdensrur`x'.tex, replace label /// 
mgroups("Population density $\geq `x'/km^2$" "Population density $<`x'/km^2$", pattern(1 0 0 1 0 0) /// 
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) /// 
varlabels(, elist(landqual \hline rural \hline)) /// 
indicate("Additional controls = *v33*" "Country FE = *country*") /// 
mtitles("\shortstack{Influence}" "Land" "Disputes" "Influence" "Land" "Disputes") ///
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// 
order(landqual) keep(landqual) ///
b(2) se(2) stats(N r2 r2_a, fmt(0 2) labels("Individuals (N)" "\(R^{2}\)" "Adj. \(R^{2}\)")) //
cd "$replication"
}
restore


* Models for Table 3
* Specifications with landqual_cell (most disaggregated measure, with ethnic group FE)
* exclude 157 Cannot match to Murdock name 
eststo m1acell: xi: qui reg q65 landqual_cell i.country1 i.name_num if name_num!=157, cluster(name_num)
eststo m1bcell: xi: qui reg TLland landqual_cell i.country1 i.name_num if name_num!=157, cluster(name_num)
eststo m1ccell: xi: qui reg TLdisputes landqual_cell i.country1 i.name_num if name_num!=157, cluster(name_num)
esttab m1*cell, order(landqual_cell) drop(*country* *name_num*) $esttabformat
eststo m2acell: xi: qui reg q65 landqual_cell i.country1 i.name_num rural if name_num!=157, cluster(name_num)
eststo m2bcell: xi: qui reg TLland landqual_cell i.country1 i.name_num rural if name_num!=157, cluster(name_num)
eststo m2ccell: xi: qui reg TLdisputes  landqual_cell i.country1 i.name_num rural if name_num!=157, cluster(name_num)
esttab m2*cell, order(landqual_cell rural) drop(*country* *name_num*) $esttabformat

* Table 3. Table with landqual at the CELL level
preserve
cd "$figures_tables"
label var landqual_cell "Land quality (2002)"
label var rural "Rural sampling unit indicator"
esttab m1acell m2acell m1bcell m2bcell m1ccell m2ccell using m1_m2_cell.tex, replace label /// 
mgroups("Influence" "Land" "Disputes", pattern(1 0 1 0 1 0) /// 
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) /// 
varlabels(, elist(landqual_cell \hline rural \hline)) /// 
indicate("Country FE = *country*" "Ethnic group FE = *name*") /// 
nomtitles /// 
nonotes star(\dag 0.10 * 0.05 ** 0.01) ///  
order(landqual_cell) keep(landqual_cell rural) ///
b(2) se(2) stats(N r2 r2_a, fmt(0 2) labels("Individuals (N)" "\(R^{2}\)" "Adj. \(R^{2}\)")) //
cd "$replication"
restore



** APPENDIX TABLES ** 


* Table A.2. Correlation table with bivariate regressions of our pre-colonial centralization measures and agricultural measures (contemporary and pre-colonial)
* Entered manually into the .tex file
*Kate's commands
preserve
keep v33 pcs OBrienKingdom landqual v5 ecodivmaj name country1
bysort name: gen index = _n
keep if index == 1 & name!="" & name!="Cannot match to Murdock name"
pwcorr v33 pcs OBrienKingdom v5 landqual ecodivmaj, sig obs
restore


* Models for Table A.3
* Alternative measures of precolonial statehood

eststo m2apcs: xi: qui reg q65 landqual pcs v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 rural, cluster(murdock_name)
eststo m2bpcs: xi: qui reg TLland landqual pcs v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 rural, cluster(murdock_name)
eststo m2cpcs: xi: qui reg TLdisputes landqual pcs v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 rural, cluster(murdock_name)
esttab m2*pcs, order(landqual) drop(*country*) $esttabformat

eststo m2aob: xi: qui reg q65 landqual  OBrienKingdom v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 rural, cluster(murdock_name)
eststo m2bob: xi: qui reg TLland landqual  OBrienKingdom v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 rural, cluster(murdock_name)
eststo m2cob: xi: qui reg TLdisputes landqual  OBrienKingdom v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 rural, cluster(murdock_name)
esttab m2*ob, order(landqual) drop(*country*) $esttabformat

* Table A.3 - using Paine's PCS measure and OBrienKingdom measure
preserve
cd "$figures_tables"
label var landqual "Land quality (2002)"
label var lnpopd00 "Population density (2000)"
label var v5 "Pre-colonial dependence on agriculture"
label var pcs "Pre-colonial state indicator (Paine)"
label var OBrienKingdom "Pre-colonial state indicator (O'Brien)"
esttab m2apcs m2aob m2bpcs m2bob m2cpcs m2cob using m2_pcs_ob.tex, replace label /// 
mgroups("Influence" "Land" "Disputes", pattern(1 0 1 0 1 0) /// 
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) /// 
varlabels(, elist(landqual \hline lnpopd00 \hline)) /// 
indicate("Additional controls = ecodivmaj" "Country FE = *country*") /// 
nomtitles /// 
nonotes star(\dag 0.10 * 0.05 ** 0.01) ///  
order(landqual pcs OBrienKingdom v5 lnpopd00) keep(landqual lnpopd00 pcs OBrienKingdom v5) ///
b(2) se(2) stats(N r2 r2_a, fmt(0 2) labels("Individuals (N)" "\(R^{2}\)" "Adj. \(R^{2}\)")) //
cd "$replication"
restore


* Table A.4
preserve
cd "$figures_tables"
label var landqual "Land quality (2002)"
label var ecodivmaj "Ecological diversity (2002)"
label var lnpopd00 "Population density (2000)"
label var v5 "Pre-colonial dependence on agriculture"
label var v33 "Pre-colonial political centralization"
label var cluster_power "Politically powerful ethnic cluster"
label var dist_cap100 "Distance from ethnic homeland to capital"
esttab m1a m2a m3a m1b m2b m3b m1c m2c m3c using m1_m2.tex, replace label /// 
mgroups("Influence" "Land" "Disputes", pattern(1 0 0 1 0 0 1 0 0) /// 
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) /// 
varlabels(, elist(landqual \hline rural \hline)) /// 
indicate("Country FE = *country*") /// 
nomtitles /// 
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// 
order(landqual v33 v5 lnpopd00 ecodivmaj cluster_power dist_cap100 rural) keep(landqual v5 ecodivmaj lnpopd00 v33 cluster_power dist_cap100 rural) ///
b(2) se(2) stats(N r2 r2_a, fmt(0 2) labels("Individuals (N)" "\(R^{2}\)" "Adj. \(R^{2}\)")) //
cd "$replication"
restore


* Table A.5 - same as Table A.4 but rural only
preserve
cd "$figures_tables"
label var landqual "Land quality (2002)"
label var ecodivmaj "Ecological diversity (2002)"
label var lnpopd00 "Population density (2000)"
label var v5 "Pre-colonial dependence on agriculture"
label var v33 "Pre-colonial political centralization"
label var cluster_power "Politically powerful ethnic cluster"
label var dist_cap100 "Distance from ethnic homeland to capital"
esttab m1arur m2arur m3arur m1brur m2brur m3brur m1crur m2crur m3crur using m1_m2_rur.tex, replace label /// 
mgroups("Influence" "Land" "Disputes", pattern(1 0 0 1 0 0 1 0 0) /// 
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) /// 
varlabels(, elist(landqual \hline dist_cap100 \hline)) /// 
indicate("Country FE = *country*") /// 
nomtitles /// 
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// 
order(landqual v33 v5 lnpopd00 ecodivmaj cluster_power dist_cap100) keep(landqual v5 ecodivmaj lnpopd00 v33 cluster_power dist_cap100) ///
b(2) se(2) stats(N r2 r2_a, fmt(0 2) labels("Individuals (N)" "\(R^{2}\)" "Adj. \(R^{2}\)")) //
cd "$replication"
restore


* Models for Table A.6
* Does the central government have less primary responsibility in areas with higher landqual?

eststo m1bST: xi: qui reg STland landqual v33 v5 i.country1, cluster(murdock_name)
eststo m1cST: xi: qui reg STdisputes landqual v33 v5 i.country1, cluster(murdock_name)
esttab m1*ST, order(landqual) drop(*country*) $esttabformat

eststo m2bST: xi: qui reg STland landqual v33 v5 lnpopd00 i.country1, cluster(murdock_name)
eststo m2cST: xi: qui reg STdisputes landqual v33 v5 lnpopd00 i.country1, cluster(murdock_name)
esttab m2*ST, order(landqual) drop(*country*) $esttabformat

eststo m3bST: xi: qui reg STland landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 rural, cluster(murdock_name)
eststo m3cST: xi: qui reg STdisputes landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 rural, cluster(murdock_name)
esttab m3*ST, order(landqual ecodivmaj cluster_* dist_cap100*) drop(*country*) $esttabformat

* Table A.6
preserve
cd "$figures_tables"
label var landqual "Land quality (2002)"
label var ecodivmaj "Ecological diversity (2002)"
label var lnpopd00 "Population density (2000)"
label var v5 "Pre-colonial dependence on agriculture"
label var v33 "Pre-colonial political centralization"
label var cluster_power "Politically powerful ethnic cluster"
label var dist_cap100 "Distance from ethnic homeland to capital"
esttab m1bST m2bST m3bST m1cST m2cST m3cST using m1_m2ST.tex, replace label /// 
mgroups("Land" "Disputes", pattern(1 0 0 1 0 0) /// 
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) /// 
varlabels(, elist(landqual \hline rural \hline)) /// 
indicate("Country FE = *country*") /// 
nomtitles /// 
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// 
order(landqual v33 v5 lnpopd00 ecodivmaj cluster_power dist_cap100 rural) keep(landqual v5 ecodivmaj lnpopd00 v33 cluster_power dist_cap100 rural) ///
b(2) se(2) stats(N r2 r2_a, fmt(0 2) labels("Individuals (N)" "\(R^{2}\)" "Adj. \(R^{2}\)")) //
cd "$replication"
restore


* Models for Table A.7
* Does the central government have less primary responsibility in RURAL areas with higher landqual?

eststo m1brurST: xi: qui reg STland landqual v33 v5 i.country1 if rural==1, cluster(murdock_name)
eststo m1crurST: xi: qui reg STdisputes landqual v33 v5 i.country1 if rural==1, cluster(murdock_name)
esttab m1*rurST, order(landqual) drop(*country*) $esttabformat

eststo m2brurST: xi: qui reg STland landqual v33 v5 lnpopd00 i.country1 if rural==1, cluster(murdock_name)
eststo m2crurST: xi: qui reg STdisputes landqual v33 v5 lnpopd00 i.country1 if rural==1, cluster(murdock_name)
esttab m2*rurST, order(landqual) drop(*country*) $esttabformat

eststo m3brurST: xi: qui reg STland landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 if rural==1, cluster(murdock_name)
eststo m3crurST: xi: qui reg STdisputes landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 if rural==1, cluster(murdock_name)
esttab m3*rurST, order(landqual ecodivmaj cluster_* dist_cap100*) drop(*country*) $esttabformat

* Table A.7
preserve
cd "$figures_tables"
label var landqual "Land quality (2002)"
label var ecodivmaj "Ecological diversity (2002)"
label var lnpopd00 "Population density (2000)"
label var v5 "Pre-colonial dependence on agriculture"
label var v33 "Pre-colonial political centralization"
label var cluster_power "Politically powerful ethnic cluster"
label var dist_cap100 "Distance from ethnic homeland to capital"
esttab m1brurST m2brurST m3brurST m1crurST m2crurST m3crurST using m1_m2_rurST.tex, replace label /// 
mgroups("Land" "Disputes", pattern(1 0 0 1 0 0) /// 
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) /// 
varlabels(, elist(landqual \hline dist_cap100 \hline)) /// 
indicate("Country FE = *country*") /// 
nomtitles /// 
nonotes star(\dag 0.10 * 0.05 ** 0.01) ///  
order(landqual v33 v5 lnpopd00 ecodivmaj cluster_power dist_cap100) keep(landqual v5 ecodivmaj lnpopd00 v33 cluster_power dist_cap100) ///
b(2) se(2) stats(N r2 r2_a, fmt(0 2) labels("Individuals (N)" "\(R^{2}\)" "Adj. \(R^{2}\)")) //
cd "$replication"
restore


* Models for Table A.8
* High vs. low agricultural groups
gen agric_high = .
replace agric_high = 1 if agric_prop >= 0.5 & agric_prop != . 
replace agric_high = 0 if agric_prop < 0.5 & agric_prop != . 
label var agric_high "Agricultural proportion of homeland (>0.5 = 1)"

eststo m3a_ruragrich: xi: qui reg q65 landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 if agric_high==1 & rural==1, cluster(murdock_name)
eststo m3b_ruragrich: xi: qui reg TLland landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 if agric_high==1 & rural==1, cluster(murdock_name)
eststo m3c_ruragrich: xi: qui reg TLdisputes landqual lnpopd00 v33 v5 i.country1 ecodivmaj cluster_power dist_cap100 if agric_high==1 & rural==1, cluster(murdock_name)
eststo m3a_ruragricl: xi: qui reg q65 landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 if agric_high==0 & rural==1, cluster(murdock_name)
eststo m3b_ruragricl: xi: qui reg TLland landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 if agric_high==0 & rural==1, cluster(murdock_name)
eststo m3c_ruragricl: xi: qui reg TLdisputes landqual lnpopd00 v33 v5 i.country1 ecodivmaj cluster_power dist_cap100 if agric_high==0 & rural==1, cluster(murdock_name)

esttab m3*_ruragrich m3*_ruragricl, order(landqual ecodivmaj cluster_* dist_cap100*) drop(*country*) $esttabformat

*Table A.8
preserve
cd "$figures_tables"
label var landqual "Land quality (2002)"
label var ecodivmaj "Ecological diversity (2002)"
label var lnpopd00 "Population density (2000)"
label var v5 "Pre-colonial dependence on agriculture"
label var v33 "Pre-colonial political centralization"
label var cluster_power "Politically powerful ethnic cluster"
label var dist_cap100 "Distance from ethnic homeland to capital"
esttab m3a_ruragrich m3b_ruragrich m3c_ruragrich m3a_ruragricl m3b_ruragricl m3c_ruragricl using main_results_ruragrich.tex, replace label /// 
mgroups("Majority agricultural land" "Minority agricultural land", pattern(1 0 0 1 0 0) /// 
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) /// 
varlabels(, elist(landqual \hline rural \hline)) /// 
indicate("Additional controls = *v33*" "Country FE = *country*") /// 
mtitles("\shortstack{Influence}" "Land" "Disputes" "Influence" "Land" "Disputes") ///
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// 
order(landqual) keep(landqual) ///
b(2) se(2) stats(N r2 r2_a, fmt(0 2) labels("Individuals (N)" "\(R^{2}\)" "Adj. \(R^{2}\)")) //
cd "$replication"
restore


* Models for Table A.9
* Main results (main_results.tex, Table 1) (m3a m3b m3c m3arur m3brur m3crur) but adding agriculture proportion as control (agric_prop)

eststo m3a_agric: xi: qui reg q65 landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 rural agric_prop, cluster(murdock_name)
eststo m3b_agric: xi: qui reg TLland landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 rural agric_prop, cluster(murdock_name)
eststo m3c_agric: xi: qui reg TLdisputes landqual lnpopd00 v33 v5 i.country1 ecodivmaj cluster_power dist_cap100 rural agric_prop, cluster(murdock_name)
esttab m3*_agric, order(landqual ecodivmaj cluster_* dist_cap100* agric*) drop(*country*) $esttabformat

eststo m3arur_agric: xi: qui reg q65 landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 agric_prop if rural==1, cluster(murdock_name)
eststo m3brur_agric: xi: qui reg TLland landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 agric_prop if rural==1, cluster(murdock_name)
eststo m3crur_agric: xi: qui reg TLdisputes landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 agric_prop if rural==1, cluster(murdock_name)
esttab m3*rur_agric, order(landqual ecodivmaj cluster_* dist_cap100* agric*) drop(*country*) $esttabformat

* Table A.9
preserve
cd "$figures_tables"
label var landqual "Land quality (2002)"
label var ecodivmaj "Ecological diversity (2002)"
label var lnpopd00 "Population density (2000)"
label var v5 "Pre-colonial dependence on agriculture"
label var v33 "Pre-colonial political centralization"
label var cluster_power "Politically powerful ethnic cluster"
label var dist_cap100 "Distance from ethnic homeland to capital"
esttab m3a_agric m3b_agric m3c_agric m3arur_agric m3brur_agric m3crur_agric using main_results_agric.tex, replace label /// 
mgroups("Full sample" "Rural sample", pattern(1 0 0 1 0 0) /// 
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) /// 
varlabels(, elist(landqual \hline rural \hline)) /// 
indicate("Country FE = *country*") /// 
mtitles("\shortstack{Influence}" "Land" "Disputes" "Influence" "Land" "Disputes") ///
nonotes star(\dag 0.10 * 0.05 ** 0.01) ///  
order(landqual agric_prop v33 v5 lnpopd00 ecodivmaj cluster_power dist_cap100 rural) keep(landqual agric_prop  v5 ecodivmaj lnpopd00 v33 cluster_power dist_cap100 rural) ///
b(2) se(2) stats(N r2 r2_a, fmt(0 2) labels("Individuals (N)" "\(R^{2}\)" "Adj. \(R^{2}\)")) //
cd "$replication"
restore


* Models for Tables A.11 and A.12
* Mechanisms: population density with 25km and 50km cutoffs, full sample

foreach x in 25 50 {
sum popd00, d
eststo popdens`x'h_q65: xi: reg q65 landqual v33 v5 i.country1 ecodivmaj cluster_power dist_cap100 rural if  popd00>=`x', cluster(murdock_name)
eststo popdens`x'l_q65: xi: reg q65 landqual v33 v5 i.country1 ecodivmaj cluster_power dist_cap100 rural if  popd00<`x', cluster(murdock_name)

eststo popdens`x'h_land: xi: reg TLland landqual v33 v5 i.country1 ecodivmaj cluster_power dist_cap100 rural if  popd00>=`x', cluster(murdock_name)
eststo popdens`x'l_land: xi: reg TLland landqual v33 v5 i.country1 ecodivmaj cluster_power dist_cap100 rural if  popd00<`x', cluster(murdock_name)

eststo popdens`x'h_disp: xi: reg TLdisputes landqual v33 v5 i.country1 ecodivmaj cluster_power dist_cap100 rural if  popd00>=`x', cluster(murdock_name)
eststo popdens`x'l_disp: xi: reg TLdisputes landqual v33 v5 i.country1 ecodivmaj cluster_power dist_cap100 rural if  popd00<`x', cluster(murdock_name)
}
esttab popdens25h* popdens25l*, order(landqual v33) drop(*country*) $esttabformat
esttab popdens50h* popdens50l*, order(landqual v33) drop(*country*) $esttabformat

* Tables A.11 and A.12
preserve
foreach x in 25 50 {
cd "$figures_tables"
label var landqual "Land quality (2002)"
esttab popdens`x'h_q65 popdens`x'h_land popdens`x'h_disp popdens`x'l_q65 popdens`x'l_land popdens`x'l_disp using popdens`x'.tex, replace label /// 
mgroups("Population density $\geq `x'/km^2$" "Population density $<`x'/km^2$", pattern(1 0 0 1 0 0) /// 
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) /// 
varlabels(, elist(landqual \hline rural \hline)) /// 
indicate("Additional controls = *v33*" "Country FE = *country*") /// 
mtitles("\shortstack{Influence}" "Land" "Disputes" "Influence" "Land" "Disputes") ///
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// 
order(landqual) keep(landqual) ///
b(2) se(2) stats(N r2 r2_a, fmt(0 2) labels("Individuals (N)" "\(R^{2}\)" "Adj. \(R^{2}\)")) //
cd "$replication"
}
restore


* Models for Table A.13
gen landqualxcustom = landqual*custom
label var landqualxcustom "Land quality x customary land interaction"

* rural sampling units
eststo m3arur_custom: xi: qui reg q65 landqual custom  v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 if rural==1, cluster(murdock_name)
eststo m3brur_custom: xi: qui reg TLland landqual custom  v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 if rural==1, cluster(murdock_name)
eststo m3crur_custom: xi: qui reg TLdisputes landqual custom  v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 if rural==1, cluster(murdock_name)
esttab m3*rur_custom, order(landqual *custom ecodivmaj cluster_* dist_cap100*) drop(*country*) $esttabformat

* full sample (urban and rural sampling units)
eststo m3a_custom: xi: qui reg q65 landqual custom  v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 rural, cluster(murdock_name)
eststo m3b_custom: xi: qui reg TLland landqual custom  v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 rural, cluster(murdock_name)
eststo m3c_custom: xi: qui reg TLdisputes landqual custom  lnpopd00 v33 v5 i.country1 ecodivmaj cluster_power dist_cap100 rural, cluster(murdock_name)
esttab m3*_custom, order(landqual *custom rural ecodivmaj cluster_* dist_cap100*) drop(*country*) $esttabformat

* Table A.13
preserve
cd "$figures_tables"
label var landqual "Land quality (2002)"
label var ecodivmaj "Ecological diversity (2002)"
label var lnpopd00 "Population density (2000)"
label var v5 "Pre-colonial dependence on agriculture"
label var v33 "Pre-colonial political centralization"
label var cluster_power "Politically powerful ethnic cluster"
label var dist_cap100 "Distance from ethnic homeland to capital"
esttab m3a_custom m3b_custom m3c_custom m3arur_custom m3brur_custom m3crur_custom using main_results_custom.tex, replace label /// 
mgroups("Full sample" "Rural sample", pattern(1 0 0 1 0 0) /// 
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) /// 
varlabels(, elist(landqual \hline rural \hline)) /// 
indicate("Country FE = *country*") /// 
mtitles("\shortstack{Influence}" "Land" "Disputes" "Influence" "Land" "Disputes") ///
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// 
order(landqual custom v33 v5 lnpopd00 ecodivmaj cluster_power dist_cap100 rural) keep(landqual custom v5 ecodivmaj lnpopd00 v33 cluster_power dist_cap100 rural) ///
b(2) se(2) stats(N r2 r2_a, fmt(0 2) labels("Individuals (N)" "\(R^{2}\)" "Adj. \(R^{2}\)")) //
cd "$replication"
restore


* Models for Table A.14
* Q50h. Corruption: traditional leaders 
* Q54c. Traditional leaders listen 
* and Q49i. Trust traditional leaders

eststo m3q50h: xi: qui reg q50h landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 rural, cluster(murdock_name)
eststo m3q54c: xi: qui reg q54c landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 rural, cluster(murdock_name)
eststo m3q49i: xi: qui reg q49i landqual lnpopd00 v33 v5 i.country1 ecodivmaj cluster_power dist_cap100 rural, cluster(murdock_name)
eststo m3q66: xi: qui reg q66 landqual lnpopd00 v33 v5 i.country1 ecodivmaj cluster_power dist_cap100 rural, cluster(murdock_name)
esttab m3q50h m3q54c m3q49i m3q66, order(landqual ecodivmaj cluster_* dist_cap100*) drop(*country*) $esttabformat

eststo m3q50hrur: xi: qui reg q50h landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 if rural==1, cluster(murdock_name)
eststo m3q54crur: xi: qui reg q54c landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 if rural==1, cluster(murdock_name)
eststo m3q49irur: xi: qui reg q49i landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 if rural==1, cluster(murdock_name)
eststo m3q66rur: xi: qui reg q66 landqual v33 v5 lnpopd00 i.country1 ecodivmaj cluster_power dist_cap100 if rural==1, cluster(murdock_name)
esttab m3q50hrur m3q54crur m3q49irur m3q66rur, order(landqual ecodivmaj cluster_* dist_cap100*) drop(*country*) $esttabformat

*Table A.14
preserve
cd "$figures_tables"
label var landqual "Land quality (2002)"
label var ecodivmaj "Ecological diversity (2002)"
label var lnpopd00 "Population density (2000)"
label var v5 "Pre-colonial dependence on agriculture"
label var v33 "Pre-colonial political centralization"
label var cluster_power "Politically powerful ethnic cluster"
label var dist_cap100 "Distance from ethnic homeland to capital"
esttab m3q50h m3q54c m3q49i m3q66 m3q50hrur m3q54crur m3q49irur m3q66rur using main_results_extraction.tex, replace label /// 
mgroups("Full sample" "Rural sample", pattern(1 0 0 0 1 0 0 0) /// 
prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) /// 
varlabels(, elist(landqual \hline rural \hline)) /// 
indicate("Country FE = *country*") /// 
mtitles("\shortstack{Chief\\corrupt}" "\shortstack{Chief\\listens}" "\shortstack{Chief\\trusted}" "\shortstack{Empower\\chiefs}" "\shortstack{Chief\\corrupt}" "\shortstack{Chief\\listens}" "\shortstack{Chief\\trusted}" "\shortstack{Empower\\chiefs}") ///
nonotes star(\dag 0.10 * 0.05 ** 0.01) /// 
order(landqual v33 v5 lnpopd00 ecodivmaj cluster_power dist_cap100 rural) keep(landqual v5 ecodivmaj lnpopd00 v33 cluster_power dist_cap100 rural) ///
b(2) se(2) stats(N r2 r2_a, fmt(0 2) labels("Individuals (N)" "\(R^{2}\)" "Adj. \(R^{2}\)")) //
cd "$replication"
restore